home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Communications / Divers / DinkClass ƒ / DinkClass / DApplication.h < prev    next >
Encoding:
Text File  |  1992-12-31  |  5.3 KB  |  191 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        DApplication.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Mark Gross
  7.  
  8.     Copyright:    © 1992 by Applied Technical Software, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <4>    12/31/92    MTG        making the code conditionaly compiled so         that I am
  13.                                     always working with a current         version in either think c
  14.                                     or MPW C++
  15.          <3>    11/14/92    MTG        Bringing the C++ version up to date WRT the ThinkC version.
  16.          <2>     9/20/92    MTG        Bringing the C++ code up todate with the THINK C version
  17.  
  18.     To Do:
  19. */
  20.  
  21.  
  22. // This is the class declaration of the DApplication class.
  23. #ifndef __DAPPLICATION__
  24. #define __DAPPLICATION__
  25.  
  26. #include "DListStuff.h"
  27. #include "DEventHandler.h"
  28. class DDocument; // forward declaration 
  29.  
  30. class DApplication : public DEventHandler
  31. {
  32.  
  33. public:
  34.  
  35.     Boolean fInBackground;
  36.  
  37.     DApplication(void);
  38.     ~DApplication(void);
  39.  
  40. protected:
  41.  
  42.     unsigned long    fSleepVal;
  43.     RgnHandle fCursorRgn;
  44.     DEventHandler*    fTarget;
  45.     
  46.     DIterator*    fIterator;
  47.             // an iterator for use in place of the local iterators
  48.             // which have to be created and destroyed in tight loops ( like in Idle procs)
  49.     
  50.     DList*  fEventHandlers;
  51.             // This list is needed because I'm not using a doubly linked list to
  52.             // implement the message passing scheam within the DEventHandler class
  53.             // and to clean up when quitting the application
  54.             
  55.     DList* fDeadHandlers;
  56.             // This list is needed because a) the signely linked list shceem and
  57.             // b) the fact that more than one event handler could died in one
  58.             // event loop pass.
  59.             
  60.     Boolean FlushDeadHandlers(void);
  61.             // Gets called from the gApplications nullEvent handleing
  62.             // routeen, if the list of deadHandlers is not empty.  It
  63.             // frees/deletes all the elements in that list.
  64.  
  65. // 
  66. // The Following members and meber functions are in support of the 
  67. // enent handling scheem implemented within this class library.
  68. // These are the First Crack event handling methods
  69. //
  70.     virtual void MouseDown(EventRecord *theEvent);
  71.         // Supports menu selections and window selections
  72.         // when mouseDown happens in a inactive window or passes the 
  73.         // handleMouseDown message down the fTarget chain.
  74.         
  75.     virtual void NullEvent(EventRecord *theEvent);
  76.     virtual void ActivateEvt(EventRecord *theEvent);
  77.  
  78.  
  79.     virtual void AutoKey(EventRecord *theEvent);
  80.     virtual void KeyDown(EventRecord *theEvent);                    
  81.  
  82.     virtual void DiskEvt(EventRecord *theEvent);
  83.  
  84.     virtual void HighLevelEvent(EventRecord *theEvent);
  85.     virtual void OSEvent(EventRecord *theEvent);
  86.     virtual void UpdateEvt(EventRecord *theEvent);
  87.     
  88. public:
  89.     
  90.     Boolean fDone;
  91.     Boolean InitApp(void);
  92.         // set up lists and put any members into a 
  93.         // safe state before the rest of the application starts roling.
  94.     
  95.     Boolean InstalHandler( DEventHandler *addMe);
  96.     Boolean RemoveHandler( DEventHandler *killMe);
  97.         // Take killMe out of the list of fEventHandlers and updates
  98.         // and refrences to the killMe instance to point to killMe->nextHandler
  99.         // It also inserts killMe into the list of fDeadHandlers which will get 
  100.         // flushed when a NULL event comes around.  It couldn't be deleted
  101.         // otherwise because of the possible reslut in deleting
  102.         // the dead object while one of its methods on the stack.
  103.             
  104.     virtual void EventLoop(void);
  105.         // parses the events to the first crack handlers.
  106.         // virtual because in the Comunication tool box 
  107.         // demo I needed to call tmidle every time through the
  108.         // event loop....
  109.         
  110.     Boolean CleanUp(void);    
  111.         // goes through and has all the fEventHandlers kill them selves
  112.         // and frees up any used memory
  113.     
  114.     virtual void HandleMenuChoice(short menuID, short menuItem);            
  115.     virtual void SetUpMenues(void);
  116.     
  117. protected:
  118.     
  119.     virtual void ClearMenus(void);
  120.  
  121. // This next section are the functions supporting the multiple
  122. // documents and file handleing for the DApplication class.
  123.  
  124. public:
  125.  
  126.     OSType        fCreator;
  127.     OSType        fClipType;
  128.     OSType        fMainFileType;
  129.             // set these members in the main function!!
  130.  
  131.     Handle    fClipData;
  132.         // access is needed for the Document objects to do the copy
  133.         // and past methods.
  134.     
  135.     virtual DDocument* MakeDDoc(Boolean OpenFromFile);
  136.         // instaniates a new DDocument object and calls
  137.         // it initialization function which will look 
  138.         // for a disk file to read in the data from if
  139.         // OpenFromFile is true.
  140.  
  141.     virtual int GetFileType(OSType *typeList);
  142.         // fills the SFTypeList array and returns the number of Items
  143.         // the number of Items is limited to 4.  The OS can do better BUT
  144.         // to SFTypeList is defined for 4 items and its easyer than worrying
  145.         // about if the pointer passed to this function has been alocated correctly.
  146.         
  147. private:
  148.     
  149.     void    GetClipFromSystem(void);
  150.     void    GiveClipToSystem(void);
  151.     
  152. public:
  153.     Handle    GetClipCopyFromApp(OSType *type);
  154.         // allocates memory the caller needs to maintain.
  155.         
  156.     void    GiveDataToApp(Handle data, OSType type);
  157.         // deletes existing clip and copies data into a new
  158.         // handle
  159.     
  160. };//end of class declaration
  161.  
  162. #define SLEEPVAL 9
  163. #define BACKGROUNDSLEEP 0x0FFFFFFF
  164. #define kDITop 0x0050
  165. #define kDILeft 0x0070
  166.  
  167. #define    rMenuBarID    128
  168. #define rAppleMenu    128
  169. #define    rFileMenu    129
  170. #define    rAboutIDBox    128
  171.  
  172. #define iAbout    1
  173.  
  174. #define    iNew    1
  175. #define    iOpen    2
  176. #define    iClose        4
  177. #define    iSave        5
  178. #define    iSaveAs        6
  179. #define    iPageSetup    8
  180. #define    iPrint        9
  181. #define    iQuit    11
  182.  
  183. #define    rEditMenu        130
  184. #define    iUndo        1
  185. #define    iCut        3
  186. #define    iCopy        4
  187. #define iPaste        5
  188. #define    iClear        6
  189. #define    iSelectAll    8
  190.  
  191. #endif __DAPPLICATION__